package com.example.stumanager.admin;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.stumanager.R;
import com.example.stumanager.database.UserSql;
import com.example.stumanager.entity.UserEntity;

/**
 * 查询学生信息
 */
public class AdminQueryStudentsPage extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.admin_query_students_page);

        TextView info=findViewById(R.id.info);
        EditText id=findViewById(R.id.id);
        UserSql db=new UserSql(this);

        Button d=findViewById(R.id.d);
        Button re=findViewById(R.id.re);
        re.setOnClickListener(view -> finish());

        d.setOnClickListener(view -> {
            UserEntity c=db.getById(id.getText().toString());
            if(c==null){
                Toast.makeText(AdminQueryStudentsPage.this, "学号不存在", Toast.LENGTH_SHORT).show();
                info.setText("学号不存在");
                return;
            }
            String str="学号："+c.getNumber()+"\n";
            str+="姓名："+c.getName()+"\n";
            str+="密码："+c.getName()+"\n";
            str+="宿舍："+c.getName()+"\n";
            str+="班级："+c.getDormitory() ;
            info.setText(str);

        });

    }
}